﻿namespace ch11.binary.wasm_reader
{
    public partial struct WasmReader
    {
        private IfArgs ReadIfArgs()
        {
            var args = new IfArgs();
            byte end;
            args.Bt = ReadBlockType();
            (args.Instrs1, end) = ReadInstructions();
            if (end != OpCodes.Else) return args;
            (args.Instrs2, end) = ReadInstructions();
            if (end != OpCodes.End)
            {
                Panic.Run("invalid block end: {0:D}", end);
            }

            return args;
        }
    }
}